﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Light.Framework.Model;
using Light.Utility;

namespace Light.Framework.Contract
{
    public interface IUserComponent : IComponent<User>, ILogin
    {
        /// <summary>
        ///  根据用户名获取
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        User GetUserByName(string name);
        /// <summary>
        /// 根据手机号码获取用户信息
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        User GetUserByPhone(string phone);
        /// <summary>
        /// 根据第三方登录OpenID获取用户信息
        /// </summary>
        /// <param name="type">QQ/微信/微博</param>
        /// <param name="openId"></param>
        /// <returns></returns>
        User GetUserByOpenID(User.OpenType type, string openId);

        /// <summary>
        /// 根据微信用户的UnionID获取用户信息
        /// </summary>
        /// <param name="unionId"></param>
        /// <returns></returns>
        User GetUserByUnionID(string unionId);

        /// <summary>
        /// 根据用户的令牌获取用户信息（过期时间为1个月）
        /// </summary>
        /// <param name="accessToken"></param>
        /// <returns></returns>
        User GetUserByToken(string accessToken);

        /// <summary>
        /// 根据当前用户的客户端信息自动生成一个token，获取用户信息
        /// </summary>
        /// <returns></returns>
        User GetUserByToken();

        OperateResult ResetPassword(int id, string newpassword);
        OperateResult ResetPassword(string username, string newpassword);
        OperateResult ChangePassword(string username, string oldpassword, string newpassword);

        /// <summary>
        /// 获取机构下的第一个用户
        /// </summary>
        /// <param name="org"></param>
        /// <returns></returns>
        User Get(Organization org);
    }
}
